package com.tvunetworks.center.user.mapper;

import com.tvunetworks.center.user.model.RoleUser;
import com.tvunetworks.center.user.model.param.GetSonUserNoRelationRoleIdParam;
import com.tvunetworks.center.user.model.param.GetUserByRoleIdParam;
import com.tvunetworks.center.user.model.vo.GetUserByRoleIdVo;
import com.tvunetworks.center.user.model.vo.RoleUserVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author Etan Yang
 * @data: 2021/4/7 15:22
 * @program: tvucc-aggregator
 * @description:
 */

public interface RoleUserMapper extends Mapper<RoleUser> {


    /**
     * 根据roleId获取所有的用户信息
     * @param roleId roleId
     * @return List
     */
    List<RoleUser> getByRoleId(@Param("roleId") String roleId);

    /**
     * 根据roleId删除RoleUser
     * @param roleId roleId
     * @return int
     */
    int deleteByRoleId(@Param("roleId")String roleId);

    /**
     * 根据userId获取RoleUser
     * @param userId userId
     * @return RoleUser
     */
    RoleUser getByUserId(@Param("userId") String userId);

    /**
     * 根据userId获取roleId和roleName
     * @param userId userId
     * @return RoleUserVo
     */
    RoleUserVo getUserRoleVoByUserId(@Param("userId") String userId);

    /**
     * 获取指定role下的子账号
     * @param param param
     * @return List
     */
    List<GetUserByRoleIdVo> pageUserByRoleId(@Param("param") GetUserByRoleIdParam param);

    /**
     * 根据userId修改roleId
     * @param userId userId
     * @param roleId roleId
     * @return int
     */
    int updateRoleIdByUserId(@Param("userId") String userId, @Param("roleId") String roleId);

    /**
     * 根据userId删除RoleUser
     * @param userId userId
     * @return int
     */
    int deleteByUserId(@Param("userId") String userId);

    /**
     * 获取admin账号下没有该role的子账号
     * @param param param
     * @return List
     */
    List<GetUserByRoleIdVo> getSonUserNoRelationRoleId(GetSonUserNoRelationRoleIdParam param);
}
